package com.bvbot.core.order;

import com.bvbot.core.BvBotException;

public class Buy {

	public int getGramsToBuy() {
		return gramsToBuy;
	}

	public void setGramsToBuy(int gramsToSell) {
		this.gramsToBuy = gramsToSell;
	}

	public int getGramsBought() {
		return gramsBought;
	}

	public void setGramsBought(int gramsSold) {
		this.gramsBought = gramsSold;
	}

	public Buy(int gramsToSell, int gramsSold) {
		super();
		this.gramsToBuy = gramsToSell;
		this.gramsBought = gramsSold;
	}

	private int gramsToBuy = -1;
	private int gramsBought = -1;

	public boolean allIsBought() {
		boolean result = false;
		if ((gramsToBuy != -1) && (gramsBought != -1)) {
			result = (gramsToBuy <= gramsBought);
		}
		return result;
	}

	public int getNextOfferGramNumber() {
		if (gramsToBuy < 0) {
			BvBotException
					.exit("Impossible to compute getNextOfferGramNumber : gramsToBuy is incorrect : "
							+ gramsToBuy);
		}
		int gb = 0;
		if (gramsBought >= 0) {
			gb = gramsBought;
		}
		return gramsToBuy - gb;
	}

	public void declareBoughtGrams(int value) {
		if (gramsBought == -1) {
			gramsBought = 0;
		}
		gramsBought = gramsBought + value;
	}
}
